{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import string\n",
    "import subprocess\n",
    "\n",
    "import frykit.shp as fshp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "chrs = list(string.printable[:-2])\n",
    "for name in (\n",
    "    fshp.get_cn_province_names()\n",
    "    + fshp.get_cn_city_names()\n",
    "    + fshp.get_cn_district_names()\n",
    "):\n",
    "    chrs.extend(name)\n",
    "chrs = list(set(chrs))\n",
    "chrs.sort()\n",
    "line = ''.join(chrs)\n",
    "line"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('chrs.txt', 'w', encoding='utf-8') as f:\n",
    "    f.write(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "subprocess.run(\n",
    "    [\n",
    "        'fonttools',\n",
    "        'subset',\n",
    "        'SourceHanSansSC-Normal.otf',\n",
    "        '--text-file=chrs.txt',\n",
    "        '--output-file=zh_font.otf',\n",
    "    ]\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
